/*
 *  sparsematrixslu.h
 *  EPPI-0.0
 *
 *  Created by Juan Carlos García Orden on 19/11/07.
 *
 */
#ifndef _sparsematrixslu_h_
#define _sparsematrixslu_h_

#include <iostream>
#include <vector>
#include "sparsematrix.h"
#include "slu_ddefs.h"
#include "mpi.h"

using namespace std;

class sparseMatrixSLU : public sparseMatrix
{
public:
	SuperMatrix    A, L, U;
        SuperMatrix    B, X;
	long lwork;
	void	*work;
	superlu_options_t options;
	SuperLUStat_t stat;
	double* rhsb;
	double* rhsx;
	int	*perm_r;	/* row permutations from partial pivoting */
    int	*perm_c;	/* column permutation vector */
    int	*etree;
    char	equed[1];
    double	*R, *C;
	double rpg, rcond;
    double	*ferr, *berr;
	mem_usage_t    mem_usage;
	int info;
	/*	Data members from the base class sparseMatrix
	 int n;
	 int* ia;
	 int* ja;
	 double* values;
	 int nnz;
	 int nrhs;	 
	*/
	
public:
	sparseMatrixSLU();
	sparseMatrixSLU(int, int);
	~sparseMatrixSLU();
		
	/** Virtual functions from base */
	void initMatrices(void);
	void initVectors(int);
	void factorize(int);
	void subsSolve(vector<double>&);
//Arma	void subsSolve(rowvec &);
	void subsSolve(RowVectorXd &);
	void subsSolve(VectorXd &);
	void subsSolveTrans(vector<vector<double> >&);
//	void subsSolveTrans(double*);
//Arma	void subsSolveTrans(mat &);
	void subsSolveTrans(MatrixXd &);
	void subsSolveTrans(SuperMatrix&, SuperMatrix&);
	void copyMatrix(sparseMatrix*);
	
	/** Local functions */
};
#endif
